import request from "@/utils/request";
//查询员工列表数据
export const queryPageApi = (name, degree, clazzId, page, pageSize) => {
  // 根据API请求健壮性规范，只传递有效的非空参数
  let url = '/students?';
  if (name !== undefined && name !== null && name !== '') url += `name=${name}&`;
  if (degree !== undefined && degree !== null && degree !== '') url += `degree=${degree}&`;
  if (clazzId !== undefined && clazzId !== null && clazzId !== '') url += `clazzId=${clazzId}&`;
  url += `page=${page}&pageSize=${pageSize}`;
  
  return request.get(url);
}

//新增
export const addApi = (std) =>  request.post('/students', std);

//根据ID查询
export const queryInfoApi = (id) =>  request.get(`/students/${id}`);

//修改
export const updateApi = (std) =>  request.put('/students', std);

//删除
export const deleteApi = (ids) =>  request.delete(`/students/${ids}`);

//违纪处理
export const handleViolationApi = (id, score) =>  request.put(`/students/violation/${id}/${score}`);